package com.matt.controller.estimate;

import com.dotflat.dashboard.vo.ChildrenClassCheckVO;
import com.dotflat.util.excelUtil.ExcelUtil;
import com.matt.commons.model.StatusResponse;
import com.matt.domain.estimate.TeacherExtendEstimate;
import com.matt.domain.estimate.vo.TeacherEstimateVO;
import com.matt.foundation.query.ClassesQuery;
import com.matt.service.estimate.TeacherEstimateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static com.matt.foundation.constant.RequestConstant.TICKET;

@RestController
@RequestMapping("/estimate/teacher")
@Slf4j
@Api(tags = "教师评价")
public class TeacherEstimateController {
    @Autowired
    private TeacherEstimateService teacherEstimateService;

    @GetMapping("/list")
    @ApiOperation(value = "查询教师评论")
    public StatusResponse TeacherList(@RequestHeader(TICKET) String ticket, String teacherName, Integer pageNum, Integer pageSize, String areaId) {
//        Page<TeacherExtendEstimate> page = teacherEstimateService.getPage(teacherName, pageNum, pageSize);
        return StatusResponse.success(teacherEstimateService.getPage(ticket, teacherName, pageNum, pageSize, areaId));
    }


    @PostMapping("/postList")
    @ApiOperation(value = "查询教师评论")
    public StatusResponse TeacherList(@RequestBody TeacherExtendEstimate teacherExtendEstimate) {
//        Page<TeacherExtendEstimate> page = teacherEstimateService.getPage(teacherName, pageNum, pageSize);
        return StatusResponse.success(teacherEstimateService.getPageList(teacherExtendEstimate));
    }


    @PostMapping("/getById")
    @ApiOperation(value = "查询教师评论详情")
    public StatusResponse teacherDetail(@RequestHeader(TICKET) String ticket, @RequestBody TeacherExtendEstimate teacherExtendEstimate) {
//        Page<TeacherExtendEstimate> page = teacherEstimateService.getPage(teacherName, pageNum, pageSize);
        return StatusResponse.success(teacherEstimateService.teacherDetail(ticket, teacherExtendEstimate));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增教师评论")
    public StatusResponse addTeacherEstimate(@RequestBody TeacherExtendEstimate teacherExtendEstimate) {
        return StatusResponse.success(teacherEstimateService.addTeacherEstimate(teacherExtendEstimate));
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改教师评论")
    public StatusResponse updateTeacherEstimate(@RequestBody TeacherExtendEstimate teacherExtendEstimate) {

        return StatusResponse.success(teacherEstimateService.updateTeacherEstimate(teacherExtendEstimate));
    }

    @GetMapping("/delete")
    @ApiOperation(value = "删除教师评论")
    public StatusResponse deleteTeacherEstimate(String teacherEstimateId) {
        TeacherExtendEstimate teacherExtendEstimate = new TeacherExtendEstimate();
        teacherExtendEstimate.setId(teacherEstimateId);
        return StatusResponse.success(teacherEstimateService.deleteTeacherExtendEstimate(teacherExtendEstimate));
    }


    @ApiOperation(value = "考勤管理详情", httpMethod = "GET")
    @GetMapping("/export")
    public void exportClassCheckDetail(HttpServletResponse response, @RequestHeader(TICKET) String ticket,
                                       String teacherName, Integer pageNum, Integer pageSize, String areaId) throws IOException {
        teacherEstimateService.exportTeacherEstimate(response, ticket, teacherName, pageNum, pageSize, areaId);

    }


}
